]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspaceAnimation: Use separate WorkspaceBackground class
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 5 Dec 2025 09:06:32 +0000 (10:06 +0100)
committerMarge Bot <marge-bot@gnome.org>
Fri, 5 Dec 2025 22:34:23 +0000 (22:34 +0000)
Separating WorkspaceGroup and WorkspaceBackground allows each to
track its own set of windows without special-casing exceptions.

This will also give us more flexibility in the future, if we need
to reuse the background elsewhere. This may happen if we optionally
change the animation to a crossfade for the new `reduced-motion`
setting.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3995>

js/ui/workspaceAnimation.js

index 0045a677bc2e7d0f3bef48e3a9c578ed2c23b3b7..8d7b2594ee61edfdb27b3b12490580b53a18ebde 100644 (file)
@@ -143,29 +143,33 @@ class WorkspaceGroup extends BaseWorkspaceGroup {
         if (!this._workspace)
             return;
 
-        this._background = new Meta.BackgroundGroup();
+        this._background = new WorkspaceBackground(this._workspace, this._monitor);
         this.add_child(this._background);
+    }
+});
+
+export const WorkspaceBackground = GObject.registerClass(
+class WorkspaceBackground extends BaseWorkspaceGroup {
+    _shouldShowWindow(window) {
+        return this._isDesktopWindow(window) &&
+            this._windowIsOnThisMonitor(window);
+    }
+
+    _createBackground() {
+        const background = new Meta.BackgroundGroup();
+        this.add_child(background);
 
         this._bgManager = new Background.BackgroundManager({
-            container: this._background,
+            container: background,
             monitorIndex: this._monitor.index,
             controlPosition: false,
         });
-        this._createDesktopWindows();
-    }
-
-    _createDesktopWindows() {
-        const desktopActors = global.get_window_actors().filter(w => {
-            return this._isDesktopWindow(w.meta_window) && this._windowIsOnThisMonitor(w.meta_window);
-        });
-        desktopActors.map(a => this._createClone(a)).forEach(clone => this._background.add_child(clone));
     }
 
     _onDestroy() {
         super._onDestroy();
 
-        if (this._workspace)
-            this._bgManager.destroy();
+        this._bgManager.destroy();
     }
 });